package com.firexxx.study.designmodel.observer;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: TODO
 * @throws:
 * @author: zhuangzhang2
 * @date: 2019/11/14 15:46
 */
public class Subject {
    private List<IObserver> observerList = new ArrayList();

    public void addObserver(IObserver observer) {
        observerList.add(observer);
    }

    public void deleteObserver(IObserver observer) {
        observerList.remove(observer);
    }

    public void notifyObversers() {
        observerList.stream().forEach(ob -> ob.response());
    }
}